//从父节点移除
window.removeNodeByParent = function (remove) {
    remove.removeFromParent();
};

//加载pfrefab
window.createPrefab = function (pfName) {
    if (pfName == null || pfName == undefined) return;
    let prefabName = cc.instantiate(pfName);
    if (prefabName) return prefabName
};

//加载资源
window.onLoadSpriteRes = function(url, type ,callback){
    cc.loader.loadRes("image/" + url, type, function (err, spriteFr) {
        if(err == null)callback(spriteFr);
        else console.log(err);
    });
};

//游戏关卡数据配置
window.getGameLevelDataConfig = function(levelNum){
    var levelData = [
        {"area":"A1","gameScene":"community","level":"1","tiWenCondition":"37.3°","passCondition":"Y_N_N_N","member":"1_0_0_0,2_0_0_0,2_0_0_0,1_0_0_0,1_0_0_0,2_0_0_0,1_0_0_0,2_0_0_0,1_0_0_0,2_0_0_0"},
        {"area":"A1","gameScene":"community","level":"2","tiWenCondition":"37.3°","passCondition":"N_Y_N_N","member":"0_1_0_0,0_1_0_0,0_0_1_0,0_2_0_0,0_2_0_0,0_1_0_0,0_1_0_0,0_2_0_0,0_1_0_0,0_1_0_0"},
        {"area":"A1","gameScene":"community","level":"3","tiWenCondition":"37.3°","passCondition":"N_N_Y_N","member":"0_0_2_0,0_0_1_0,0_0_1_0,0_0_2_0,0_0_1_0,0_0_1_0,0_0_2_0,0_0_2_0,0_0_1_0,0_0_1_0"},
        {"area":"A1","gameScene":"community","level":"4","tiWenCondition":"37.3°","passCondition":"N_N_N_Y","member":"0_0_0_1,0_0_1_0,0_0_1_0,0_0_0_2,0_0_0_1,0_0_0_2,0_0_0_1,0_0_0_1,0_0_0_1,0_0_0_2"},
        {"area":"A1","gameScene":"community","level":"5","tiWenCondition":"37.3°","passCondition":"Y_Y_N_N","member":"1_1_0_0,1_1_0_0,1_2_0_0,1_1_0_0,2_1_0_0,2_2_0_0,1_1_0_0,1_1_0_0,2_2_0_0,1_1_0_0"},
        {"area":"A1","gameScene":"community","level":"6","tiWenCondition":"37.3°","passCondition":"N_N_Y_Y","member":"0_0_1_1,0_0_1_1,0_0_2_1,0_0_2_2,0_0_1_1,0_0_2_1,0_0_1_1,0_0_1_1,0_0_2_1,0_0_2_2"},
        {"area":"B1","gameScene":"STADIUM","level":"7","tiWenCondition":"无危险物品","passCondition":"Y_N_N_N","member":"1_0_0_0,1_0_0_0,2_0_0_0,1_0_0_0,1_0_0_0,2_0_0_0,1_0_0_0,2_0_0_0,1_0_0_0,2_0_0_0"},
        {"area":"B1","gameScene":"STADIUM","level":"8","tiWenCondition":"无危险物品","passCondition":"N_Y_N_N","member":"0_1_0_0,0_1_0_0,0_0_1_0,0_2_0_0,0_2_0_0,0_1_0_0,0_1_0_0,0_2_0_0,0_1_0_0,0_1_0_0"},
        {"area":"B1","gameScene":"STADIUM","level":"9","tiWenCondition":"无危险物品","passCondition":"N_N_Y_N","member":"0_0_2_0,0_0_1_0,0_0_1_0,0_0_2_0,0_0_1_0,0_0_1_0,0_0_2_0,0_0_2_0,0_0_1_0,0_0_1_0"},
        {"area":"B1","gameScene":"STADIUM","level":"10","tiWenCondition":"无危险物品","passCondition":"N_N_N_Y","member":"0_0_0_1,0_0_1_0,0_0_1_0,0_0_0_2,0_0_0_1,0_0_0_2,0_0_0_1,0_0_0_1,0_0_0_1,0_0_0_2"},
        {"area":"B1","gameScene":"STADIUM","level":"11","tiWenCondition":"无危险物品","passCondition":"Y_Y_N_N","member":"1_1_0_0,1_1_0_0,1_2_0_0,1_1_0_0,2_1_0_0,2_2_0_0,1_1_0_0,1_1_0_0,2_2_0_0,1_1_0_0"},
        {"area":"B1","gameScene":"STADIUM","level":"12","tiWenCondition":"无危险物品","passCondition":"N_N_Y_Y","member":"0_0_1_1,0_0_1_1,0_0_2_1,0_0_2_2,0_0_1_1,0_0_2_1,0_0_1_1,0_0_1_1,0_0_2_1,0_0_2_2"},
        {"area":"C1","gameScene":"BLIND DATE","level":"13","tiWenCondition":"婚否","passCondition":"Y_N_N_N","member":"1_0_0_0,1_0_0_0,2_0_0_0,1_0_0_0,1_0_0_0,2_0_0_0,1_0_0_0,2_0_0_0,1_0_0_0,2_0_0_0"},
        {"area":"C1","gameScene":"BLIND DATE","level":"14","tiWenCondition":"婚否","passCondition":"N_Y_N_N","member":"0_1_0_0,0_1_0_0,0_0_1_0,0_2_0_0,0_2_0_0,0_1_0_0,0_1_0_0,0_2_0_0,0_1_0_0,0_1_0_0"},
        {"area":"C1","gameScene":"BLIND DATE","level":"15","tiWenCondition":"婚否","passCondition":"N_N_Y_N","member":"0_0_2_0,0_0_1_0,0_0_1_0,0_0_2_0,0_0_1_0,0_0_1_0,0_0_2_0,0_0_2_0,0_0_1_0,0_0_1_0"},
        {"area":"C1","gameScene":"BLIND DATE","level":"16","tiWenCondition":"婚否","passCondition":"N_N_N_Y","member":"0_0_0_1,0_0_1_0,0_0_1_0,0_0_0_2,0_0_0_1,0_0_0_2,0_0_0_1,0_0_0_1,0_0_0_1,0_0_0_2"},
        {"area":"C1","gameScene":"BLIND DATE","level":"17","tiWenCondition":"婚否","passCondition":"Y_Y_N_N","member":"1_1_0_0,1_1_0_0,1_2_0_0,1_1_0_0,2_1_0_0,2_2_0_0,1_1_0_0,1_1_0_0,2_2_0_0,1_1_0_0"},
        {"area":"C1","gameScene":"BLIND DATE","level":"18","tiWenCondition":"婚否","passCondition":"N_N_Y_Y","member":"0_0_1_1,0_0_1_1,0_0_2_1,0_0_2_2,0_0_1_1,0_0_2_1,0_0_1_1,0_0_1_1,0_0_2_1,0_0_2_2"},
        {"area":"D1","gameScene":"FACTORY","level":"19","tiWenCondition":"工厂职工衣","passCondition":"Y_N_N_N","member":"1_0_0_0,1_0_0_0,2_0_0_0,1_0_0_0,1_0_0_0,2_0_0_0,1_0_0_0,2_0_0_0,1_0_0_0,2_0_0_0"},
        {"area":"D1","gameScene":"FACTORY","level":"20","tiWenCondition":"工厂职工衣","passCondition":"N_Y_N_N","member":"0_1_0_0,0_1_0_0,0_0_1_0,0_2_0_0,0_2_0_0,0_1_0_0,0_1_0_0,0_2_0_0,0_1_0_0,0_1_0_0"},
        {"area":"D1","gameScene":"FACTORY","level":"21","tiWenCondition":"工厂职工衣","passCondition":"N_N_Y_N","member":"0_0_2_0,0_0_1_0,0_0_1_0,0_0_2_0,0_0_1_0,0_0_1_0,0_0_2_0,0_0_2_0,0_0_1_0,0_0_1_0"},
        {"area":"D1","gameScene":"FACTORY","level":"22","tiWenCondition":"工厂职工衣","passCondition":"N_N_N_Y","member":"0_0_0_1,0_0_1_0,0_0_1_0,0_0_0_2,0_0_0_1,0_0_0_2,0_0_0_1,0_0_0_1,0_0_0_1,0_0_0_2"},
        {"area":"D1","gameScene":"FACTORY","level":"23","tiWenCondition":"工厂职工衣","passCondition":"Y_Y_N_N","member":"1_1_0_0,1_1_0_0,1_2_0_0,1_1_0_0,2_1_0_0,2_2_0_0,1_1_0_0,1_1_0_0,2_2_0_0,1_1_0_0"},
        {"area":"D1","gameScene":"FACTORY","level":"24","tiWenCondition":"工厂职工衣","passCondition":"N_N_Y_Y","member":"0_0_1_1,0_0_1_1,0_0_2_1,0_0_2_2,0_0_1_1,0_0_2_1,0_0_1_1,0_0_1_1,0_0_2_1,0_0_2_2"},
        {"area":"E1","gameScene":"GARRISON","level":"25","tiWenCondition":"军装","passCondition":"Y_N_N_N","member":"1_0_0_0,1_0_0_0,2_0_0_0,1_0_0_0,1_0_0_0,2_0_0_0,1_0_0_0,2_0_0_0,1_0_0_0,2_0_0_0"},
        {"area":"E1","gameScene":"GARRISON","level":"26","tiWenCondition":"军装","passCondition":"N_Y_N_N","member":"0_1_0_0,0_1_0_0,0_0_1_0,0_2_0_0,0_2_0_0,0_1_0_0,0_1_0_0,0_2_0_0,0_1_0_0,0_1_0_0"},
        {"area":"E1","gameScene":"GARRISON","level":"27","tiWenCondition":"军装","passCondition":"N_N_Y_N","member":"0_0_2_0,0_0_1_0,0_0_1_0,0_0_2_0,0_0_1_0,0_0_1_0,0_0_2_0,0_0_2_0,0_0_1_0,0_0_1_0"},
        {"area":"E1","gameScene":"GARRISON","level":"28","tiWenCondition":"军装","passCondition":"N_N_N_Y","member":"0_0_0_1,0_0_1_0,0_0_1_0,0_0_0_2,0_0_0_1,0_0_0_2,0_0_0_1,0_0_0_1,0_0_0_1,0_0_0_2"},
        {"area":"E1","gameScene":"GARRISON","level":"29","tiWenCondition":"军装","passCondition":"Y_Y_N_N","member":"1_1_0_0,1_1_0_0,1_2_0_0,1_1_0_0,2_1_0_0,2_2_0_0,1_1_0_0,1_1_0_0,2_2_0_0,1_1_0_0"},
        {"area":"E1","gameScene":"GARRISON","level":"30","tiWenCondition":"军装","passCondition":"N_N_Y_Y","member":"0_0_1_1,0_0_1_1,0_0_2_1,0_0_2_2,0_0_1_1,0_0_2_1,0_0_1_1,0_0_1_1,0_0_2_1,0_0_2_2"},
        {"area":"F1","gameScene":"HIGH SCHOOL","level":"31","tiWenCondition":"校服/常服","passCondition":"Y_N_N_N","member":"1_0_0_0,1_0_0_0,2_0_0_0,1_0_0_0,1_0_0_0,2_0_0_0,1_0_0_0,2_0_0_0,1_0_0_0,2_0_0_0"},
        {"area":"F1","gameScene":"HIGH SCHOOL","level":"32","tiWenCondition":"校服/常服","passCondition":"N_Y_N_N","member":"0_1_0_0,0_1_0_0,0_0_1_0,0_2_0_0,0_2_0_0,0_1_0_0,0_1_0_0,0_2_0_0,0_1_0_0,0_1_0_0"},
        {"area":"F1","gameScene":"HIGH SCHOOL","level":"33","tiWenCondition":"校服/常服","passCondition":"N_N_Y_N","member":"0_0_2_0,0_0_1_0,0_0_1_0,0_0_2_0,0_0_1_0,0_0_1_0,0_0_2_0,0_0_2_0,0_0_1_0,0_0_1_0"},
        {"area":"F1","gameScene":"HIGH SCHOOL","level":"34","tiWenCondition":"校服/常服","passCondition":"N_N_N_Y","member":"0_0_0_1,0_0_1_0,0_0_1_0,0_0_0_2,0_0_0_1,0_0_0_2,0_0_0_1,0_0_0_1,0_0_0_1,0_0_0_2"},
        {"area":"F1","gameScene":"HIGH SCHOOL","level":"35","tiWenCondition":"校服/常服","passCondition":"Y_Y_N_N","member":"1_1_0_0,1_1_0_0,1_2_0_0,1_1_0_0,2_1_0_0,2_2_0_0,1_1_0_0,1_1_0_0,2_2_0_0,1_1_0_0"},
        {"area":"F1","gameScene":"HIGH SCHOOL","level":"36","tiWenCondition":"校服/常服","passCondition":"N_N_Y_Y","member":"0_0_1_1,0_0_1_1,0_0_2_1,0_0_2_2,0_0_1_1,0_0_2_1,0_0_1_1,0_0_1_1,0_0_2_1,0_0_2_2"}
    ];

    return levelData[levelNum - 1];
};

/**
 * @param
 * min 最小值
 * max 最大值
 * fixed 保留小数位数  默认不保留
 */
window.getRandom = function(min, max, fixed=0) {
    let differ = max - min
    let random = Math.random()
    return (min + differ * random).toFixed(fixed)
};

//初始化
window.initGameConfigData = function(){
    window.gameConfig = require("gameConfig").prototype;
    window.gameConfig.init();
};